//
//  PMineResumeCell.m
//  Btpin
//
//  Created by Vic on 2019/3/24.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PMineResumeCell.h"
#import "PSShowTextCell.h"
#import "CompanyTagsView.h"

@interface PMineResumeCell ()
{
    UILabel *lbl;
    PSShowTextCell *showCell;
}
@end

@implementation PMineResumeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    lbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, self.frame.size.height) text:@"待完善" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
    [self.contentView addSubview:lbl];
}
- (void)reloadData:(PMineResumeInfoModel *)infoModel indexPath:(NSIndexPath *)indexPath {
    lbl.hidden = NO;
    for (UIView *view in self.contentView.subviews) {
        if (view != lbl) {
            [view removeFromSuperview];
        }
    }
    switch (indexPath.section) {
        case 0: {
            if (infoModel.intentionModel) {
                lbl.hidden = YES;
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 60*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfAll text:[NSString stringWithFormat:@"%@ %@", infoModel.intentionModel.jobs_cn, infoModel.intentionModel.wage_cn] detail:[NSString stringWithFormat:@"%@ %@", infoModel.intentionModel.district_cn, infoModel.intentionModel.trade_cn] showIcon:NO rightText:nil showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 1: {
            if (infoModel.workArray && infoModel.workArray.count) {
                lbl.hidden = YES;
                PMineResumeWorkInfoModel *model = infoModel.workArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 60*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfAll text:model.company_name detail:model.job_name showIcon:((model.has_img && [model.has_img integerValue])?YES:NO) rightText:[NSString stringWithFormat:@"%@-%@", model.start_date, (model.end_date && model.end_date.length)?model.end_date:@"至今"] showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 2: {
            if (infoModel.educationArray && infoModel.educationArray.count) {
                lbl.hidden = YES;
                PMineResumeEducationInfoModel *model = infoModel.educationArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 60*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfAll text:model.school detail:[NSString stringWithFormat:@"%@ %@", model.speciality, model.education_cn] showIcon:((model.has_img && [model.has_img integerValue])?YES:NO) rightText:[NSString stringWithFormat:@"%@-%@", model.start_date, (model.end_date && model.end_date.length)?model.end_date:@"至今"] showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 3: {
            if (infoModel.trainingArray && infoModel.trainingArray.count) {
                lbl.hidden = YES;
                PMineResumeTrainingInfoModel *model = infoModel.trainingArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 60*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfAll text:model.agency detail:model.course showIcon:((model.has_img && [model.has_img integerValue])?YES:NO) rightText:[NSString stringWithFormat:@"%@-%@", model.start_date, (model.end_date && model.end_date.length)?model.end_date:@"至今"] showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 4: {
            if (infoModel.projectArray && infoModel.projectArray.count) {
                lbl.hidden = YES;
                PMineResumeProjectInfoModel *model = infoModel.projectArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 45*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfSecondaryTitle text:model.name detail:nil showIcon:((model.has_img && [model.has_img integerValue])?YES:NO) rightText:[NSString stringWithFormat:@"%@-%@", model.start_date, (model.end_date && model.end_date.length)?model.end_date:@"至今"] showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 5: {
            if (infoModel.credentArray && infoModel.credentArray.count) {
                lbl.hidden = YES;
                PMineResumeCredentInfoModel *model = infoModel.credentArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 45*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfSecondaryTitle text:model.name detail:nil showIcon:((model.has_img && [model.has_img integerValue])?YES:NO) rightText:model.recieve_date showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 6: {
            if (infoModel.languageArray && infoModel.languageArray.count) {
                lbl.hidden = YES;
                PMineResumeLanguageInfoModel *model = infoModel.languageArray[indexPath.row];
                showCell = [[PSShowTextCell alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 45*Scale) target:self psShowTextCellType:PSShowTextCellTypeOfSecondaryTitle text:[NSString stringWithFormat:@"%@ %@", model.language_cn, model.level_cn] detail:nil showIcon:NO rightText:nil showBottomLine:NO addBtn:NO];
                [self.contentView addSubview:showCell];
            }
        } break;
        case 7: {
            if (infoModel.tagsArray && infoModel.tagsArray.count) {
                lbl.hidden = YES;
                NSMutableArray *dataArray = [NSMutableArray arrayWithCapacity:0];
                for (PMineResumeTagsInfoModel *model in infoModel.tagsArray) {
                    [dataArray addObject:model.tag_cn];
                }
//                CompanyTagsView *tagView = [[CompanyTagsView alloc] initWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 55*Scale) dataArray:dataArray];
//                [self.contentView addSubview:tagView];
                
//                if (dataArray && dataArray.count) {
//                    UIScrollView *tagsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30*Scale, 5*Scale, WIDTH-60*Scale, 35*Scale)];
//                    [self addSubview:tagsScrollView];
//                    CGFloat lblWidth = (WIDTH-60*Scale)*0.25;
//                    CGFloat endX = 0;
//                    for (NSInteger i = 0; i < dataArray.count; i++) {
//                        CGFloat textWidth = [UIToolsControl textWidth:dataArray[i] size:CGSizeMake(MAXFLOAT, CompanyTagsHeight) font:Font_13]+1;
//                        CGFloat width = ((lblWidth>textWidth)?lblWidth:textWidth);
//                        UILabel *lbl = [UIToolsControl initLabelWithFrame:CGRectMake(endX, 5*Scale, width, CompanyTagsHeight) text:dataArray[i] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
//                        lbl.textAlignment = NSTextAlignmentCenter;
//                        lbl.layer.cornerRadius = 2*Scale;
//                        lbl.layer.masksToBounds = YES;
//                        lbl.layer.borderColor = THEMECOLOR_OF_TEXT_cccccc.CGColor;
//                        lbl.layer.borderWidth = 0.5;
//                        [tagsScrollView addSubview:lbl];
//                        endX = EndX(lbl)+5*Scale;
//                    }
//                    tagsScrollView.contentSize = CGSizeMake(endX+15*Scale, 0);
//                } else {
//                    UILabel *lbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 5*Scale, WIDTH-15*Scale, 35*Scale) text:@"待完善" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
//                    [self addSubview:lbl];
//                }
            }
        } break;
        default:
            break;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
